Skip to content

Misc Fixes For Help Forum#2337

Merged
ChrisLovering merged 8 commits into
mainfrom
help-forum-fixes
Nov 26, 2022
Merged

Misc Fixes For Help Forum#2337
ChrisLovering merged 8 commits into
mainfrom
help-forum-fixes

Conversation

@HassanAbouelela
Copy link
Copy Markdown
Contributor

@HassanAbouelela HassanAbouelela commented Nov 26, 2022

This PR includes a few small fixes for the help forum. Each commit includes descriptions of the issue, and the fix.

The current warning log includes the thread name, which means the log
message varies wildly between threads. This causes issues with sentry
since the actual error message gets trimmed, and sentry fails to group
issues from this log as they appear as different messages.

Signed-off-by: Hassan Abouelela <hassan@hassanamr.com>
When discord sends us the thread create event in help channels, it is
not ready to perform other operations on the thread such as getting or
pinning messages. This causes it to error out when we try to do these
actions and claim that those channels don't exist. Instead, we sleep for
a short time to try and wait for it to be ready.

Signed-off-by: Hassan Abouelela <hassan@hassanamr.com>
We try to remove the cooldown role from users before checking if the
user is still in the server, which can cause an error since the thread
object will just contain `None` as the user.

Signed-off-by: Hassan Abouelela <hassan@hassanamr.com>
The old method for detecting deleted opener messages does not seem to
work, probably because the message is fetched from a cache or similar.
Instead we simply try/except pinning the message and pass if the pinning
failed.

Signed-off-by: Hassan Abouelela <hassan@hassanamr.com>
The wait_for_deletion utility would try to remove reactions from a
message after the timeout expires, which would normally be fine. In
threads however, they can be closed while waiting for the timeout to
expire. In such a case, the bot will try to remove the reactions after
the channel has been closed and fail. A special exception was added for
this case to do nothing, since this is only a QoL feature.

Signed-off-by: Hassan Abouelela <hassan@hassanamr.com>
@HassanAbouelela HassanAbouelela added t: bug Something isn't working p: 1 - high High Priority a: help channels Related to the help channel system labels Nov 26, 2022
@HassanAbouelela HassanAbouelela marked this pull request as ready for review November 26, 2022 11:17
@HassanAbouelela HassanAbouelela marked this pull request as draft November 26, 2022 11:18
@ChrisLovering ChrisLovering marked this pull request as ready for review November 26, 2022 11:21
Similar to 555ed4e, the pagination utility needs to catch when it's
trying to act on an archived thread.

Signed-off-by: Hassan Abouelela <hassan@hassanamr.com>
In the case of an image or other media as the starter message, the
formatted message in the help DM will be empty, which is invalid for the
embed. We populate the field with some more useful text in this case.

Signed-off-by: Hassan Abouelela <hassan@hassanamr.com>
Copy link
Copy Markdown
Contributor

@shtlrs shtlrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a couple of comments

Comment thread bot/exts/help_channels/_channel.py
# Discord sends the open event long before the thread is ready for actions in the API.
# This causes actions such as fetching the message, pinning message, etc to fail.
# We sleep here to try and delay our code enough so the thread is ready in the API.
await asyncio.sleep(2)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure that 2 seconds will always be enough ? Isn't there another event we can subscribe to, like the starter message for example ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, theoretically we could wait_for an on_message event which has the same message_id as the just created thread. Since this would then mean the message was sent to us via the gateway, and is also cached in d.py

Comment thread bot/utils/messages.py Outdated
Comment thread bot/exts/help_channels/_channel.py
Comment thread bot/pagination.py
Comment thread bot/utils/messages.py Outdated
Comment thread bot/pagination.py
@HassanAbouelela HassanAbouelela force-pushed the help-forum-fixes branch 2 times, most recently from 79eb97d to 2857424 Compare November 26, 2022 12:18
Comment thread bot/utils/messages.py Outdated
raise

try:
await message.delete()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theoretically the thread could get locked between the reaction and this line

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored it again

Co-authored-by: Boris Muratov <8bee278@gmail.com>
Co-authored-by: Amrou Bellalouna <48383734+shtlrs@users.noreply.github.com>
Signed-off-by: Hassan Abouelela <hassan@hassanamr.com>
Copy link
Copy Markdown
Member

@mbaruh mbaruh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magnifique

@ChrisLovering ChrisLovering merged commit 47ea976 into main Nov 26, 2022
@ChrisLovering ChrisLovering deleted the help-forum-fixes branch November 26, 2022 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: help channels Related to the help channel system p: 1 - high High Priority t: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants